package org.jeecg.modules.userOpenid.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.userOpenid.entity.UserOpenid;
import org.jeecg.modules.userOpenid.mapper.UserOpenidMapper;
import org.jeecg.modules.userOpenid.service.IUserOpenidService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description: 用户openid关联表
 * @Author: jeecg-boot
 * @Date:   2025-10-16
 * @Version: V1.0
 */
@Service
public class UserOpenidServiceImpl extends ServiceImpl<UserOpenidMapper, UserOpenid> implements IUserOpenidService {

    @Override
    public UserOpenid getByUserId(String userId) {
        LambdaQueryWrapper<UserOpenid> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(UserOpenid::getUserId, userId);
        return this.getOne(wrapper);
    }

    @Override
    public List<UserOpenid> getByUserIds(List<String> userIds) {
        if (userIds.isEmpty()){
            return new ArrayList<>();
        } else {
            LambdaQueryWrapper<UserOpenid> wrapper = Wrappers.lambdaQuery();
            wrapper.in(UserOpenid::getUserId, userIds);
            return this.list(wrapper);
        }
    }

}
